package com.lb.design.pattern.mutipattern;

import java.util.ArrayList;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: liubin
 * Date: 2017-12-29
 * Time: 下午 3:49
 */
public class Teacher {
    //做多只能有两个班主任
    private static  int maxTeacherCount = 2;
    //
    private static ArrayList teachers = new ArrayList(maxTeacherCount);


    private static ArrayList  teacherNames = new ArrayList(maxTeacherCount);


    private static  int countNumOfTeacher = 0;


    static {
        for(int i = 0;i<maxTeacherCount;i++){
            teachers.add(new Teacher("皇帝"+i));
        }
    }


    private Teacher(){}

    private Teacher(String name){
        teacherNames.add(name);
    }


    public static Teacher getInstance(){
        Random random = new Random();
        //随便拉出来一个皇帝
        countNumOfTeacher = random.nextInt(maxTeacherCount);
        return (Teacher) teachers.get(countNumOfTeacher);
    }

    public static  void teacherName(){
        System.out.println(teacherNames.get(countNumOfTeacher));
    }




}
